package com.xiaoshuidi.cloud.module.system.controller.admin.receipt;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.module.system.controller.admin.receipt.vo.ReceiptReqVO;
import com.xiaoshuidi.cloud.module.system.controller.admin.receipt.vo.ReceiptRespVO;
import com.xiaoshuidi.cloud.module.system.service.receipt.ReceiptService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import static com.xiaoshuidi.cloud.framework.common.pojo.CommonResult.success;

@Tag(name =  "管理后台 - 收据配置")
@RestController
@RequestMapping("/system/receipt")
@Validated
public class ReceiptController {

    @Resource
    private ReceiptService receiptService;

    @GetMapping("/get")
    @Operation(summary = "根据门店id获取收据配置")
    //@PreAuthorize("@ss.hasPermission('system:dept:query')")
    public CommonResult<ReceiptRespVO> get(@RequestParam("apartmentId") Long apartmentId) {
        return success(receiptService.get(apartmentId));
    }

    @PostMapping("/save")
    @Operation(summary = "保存收据配置")
    //@PreAuthorize("@ss.hasPermission('system:dept:query')")
    public CommonResult<Boolean> save(@RequestBody ReceiptReqVO reqVO) {
        return success(receiptService.save(reqVO));
    }
}
